<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_top" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 列表条目 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="产品选择" prop="product_id">
          <template slot-scope="scope">
            {{scope.row.product_id}}
          </template>
        </el-table-column>
        <el-table-column label="数量" prop="">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pronum_no" />
          </template>
        </el-table-column>
        <el-table-column label="单价" prop="price_pro">
          <template slot-scope="scope">
            <el-input v-model="scope.row.price_pro" />
          </template>
        </el-table-column>
        <el-table-column label="交货地点" prop="" width="50">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pronum_address" />
          </template>
        </el-table-column>
        <el-table-column label="交货时间" prop="">
          <template slot-scope="scope">
            <el-date-picker v-model="scope.row.pronum_endate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
          </template>
        </el-table-column>
        <el-table-column label="简要描述" prop="" width="20">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pronum_remark" />
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 甲乙双方责任 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="选择" prop="description">
          <template slot-scope="scope">
            {{scope.row.description}}
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 付款方式 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="首次付款" prop="pay_first">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pay_first" />
          </template>
        </el-table-column>
        <el-table-column label="二次付款" prop="pay_sec">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pay_sec" />
          </template>
        </el-table-column>
        <el-table-column label="尾付款" prop="pay_end">
          <template slot-scope="scope">
            <el-input v-model="scope.row.pay_end" />
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 付款账号 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="账号选择" prop="bank">
          <template slot-scope="scope">
            {{scope.row.bank}}
            <el-button @click="popPaymentSelection('bank','bank')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 违约责任 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="责任选择" prop="break_duty">
          <template slot-scope="scope">
            {{scope.row.break_duty}}
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 其他要求 </span>
      </div>
      <el-table :data="s_top">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(s_top,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(s_top,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="选择" prop="description">
          <template slot-scope="scope">
            {{scope.row.description}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="PaymentSelectionVisible" append-to-body>
      <PaymentSelection v-if="PaymentSelectionVisible" ref="PaymentSelection" :popparams="popparams"> </PaymentSelection>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import PaymentSelection from "@/views/psi/supplychainmana/PaymentSelection";
  export default {
    name: 'ContractAddPage',
    components: {
      PaymentSelection,
    },
    props: ['popparams'],
    data() {
      return {
        PaymentSelectionVisible: false,
        PaymentSelectionValue: null,
        PaymentSelectionDesc: null,
        vueparams: this.getVUEParams(""),
        s_top: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/contractAddPage?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      contractAddPageSubmit(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/contractAddPageSubmit?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popPaymentSelection(desc, value) {
        this.PaymentSelectionVisible = true;
        this.PaymentSelectionDesc = desc;
        this.PaymentSelectionValue = value;
      },
      closePaymentSelection(value, desc) {
        this.PaymentSelectionVisible = false;
        this.$set(this.s_top, this.PaymentSelectionDesc, desc);
        this.$set(this.s_top, this.PaymentSelectionValue, value);
      },
    },
  }
</script>
